package com.shrcl.engineerprocess.domain.impl;

import com.shrcl.engineerprocess.domain.WeChatUser;
import com.shrcl.engineerprocess.domain.WeChatUserDAO;
import com.shrcl.engineerprocess.domain.impl.WeChatUserImpl;
import edu.fudan.mylang.pf.BaseDAOService;
import edu.fudan.mylang.pf.IGenericQuery;
import org.eclipse.xtext.xbase.lib.ObjectExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.springframework.stereotype.Service;

@Service("com.shrcl.engineerprocess.domain.WeChatUserDAO")
public class WeChatUserDAOImpl extends BaseDAOService<WeChatUser> implements WeChatUserDAO {
  public WeChatUser findActiveWeChatUser(final String wechatid) {
    IGenericQuery<WeChatUser> query=getObjectFactory().createGenericQuery(WeChatUser.class,"select e from com.shrcl.engineerprocess.domain.impl.WeChatUserImpl as e   where (((e.wechatid) = (:wechatid)) and ((e.excluded) = (false))) and  e.active = 1      ").setParameter("wechatid",wechatid);
    WeChatUser _uniqueResult = query.uniqueResult();
    return _uniqueResult;
  }
  
  public WeChatUser create(final Procedure1<? super WeChatUser> init) {WeChatUser weChatUser=WeChatUserImpl.create(getObjectFactory());
    final Procedure1<WeChatUser> _function = new Procedure1<WeChatUser>() {
        public void apply(final WeChatUser it) {
          init.apply(it);
          it.checkValid();
        }
      };
    WeChatUser _doubleArrow = ObjectExtensions.<WeChatUser>operator_doubleArrow(weChatUser, _function);
    return _doubleArrow;
  }
}
